import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  server: {
   cors: true, 
   open: true, 
   port: 319,
   proxy: {
     [process.env.VITE_APP_BASE_API]: {
       target: process.env.VITE_APP_SERVICE_URL,  
       changeOrigin: true,
       rewrite: (path) => path.replace(new RegExp('^' + process.env.VITE_APP_BASE_API), '' )
     }
   }
  }
})
